'*********************************** 'ATT cont Ver 0.0.1 'JA4LAO Tuneo.Ito '2007.02.27 'AT90S8535-10 '*********************************** Config Portd = Input Config Portc = Output Config Porta.0 = Input Config Porta.1 = Input Config Kbd = Portd Config Debounce = 3 Dim Q_key As Byte Dim C_key As Long Dim D_key As Long Dim E_key As Byte Dim K_key As Byte Dim I_key As Byte Dim N_key As Byte Dim M_key As Byte Dim P_key As Byte Dim N As Byte Dim Kazu_key(10) As Long Dim Moto_key(10) As Long Dim Att_data As Long Dim Out_data As Long Dim Att_step As Byte Dim O_data_1 As String * 2 Dim O_data_2 As String * 1 Dim O_data_3 As String * 1 Dim Att_data_2 As Byte Cls : Cursor Off N_key = 1 : K_key = "" Att_data = 0 : Att_step = 10 Locate 1 , 3 : Lcd "ATT =" : Locate 1 , 12 : Lcd "dbm" Locate 2 , 3 : Lcd "STEP =" : Locate 2 , 12 : Lcd "db" Main: Gosub Lcd_hyouji Gosub Nyuryoku Goto Main End Nyuryoku: Do Debounce Pina.0 , 0 , Updown , Sub K_key = Getkbd() If K_key =< 15 Then Gosub Hantei If M_key = 1 Then Gosub Settei Else End If End If Loop Return Hantei: Waitms 10 P_key = Getkbd() If P_key = K_key Then M_key = 0 Else M_key = 1 Waitms 30 End If Return Settei: Select Case K_key Case 0 To 9 Moto_key(n_key) = K_key Gosub Hyouji N_key = N_key + 1 M_key = 0 : K_key = 16 Case 15 'enter Gosub Kettei Gosub Att_dataout Case 11 'UP Att_data = Att_data - Att_step If Att_data < 0 Then Att_data = 0 Gosub Att_dataout Gosub Lcd_hyouji Case 12 'DOWN Att_data = Att_data + Att_step If Att_data => 70 Then Att_data = 69 Gosub Att_dataout Gosub Lcd_hyouji Case 13 '10db step Att_step = 10 Gosub Lcd_hyouji Case 14 '1db step Att_step = 1 Gosub Lcd_hyouji End Select Return Hyouji: Q_key = N_key : E_key = N_key -1 : D_key = 0 For I_key = 1 To Q_key If E_key = 0 Then C_key = 1 Else C_key = 10 ^ E_key End If Kazu_key(i_key) = Moto_key(i_key) * C_key E_key = E_key - 1 Next I_key For I_key = 1 To Q_key D_key = D_key + Kazu_key(i_key) Next I_key Att_data = D_key Gosub Lcd_hyouji Return Kettei: If D_key >= 70 Then D_key = 69 Att_data = D_key Gosub Lcd_hyouji D_key = 0 For I_key = 1 To N_key Moto_key(i_key) = 0 Kazu_key(i_key) = 0 Next I_key N_key = 1 : K_key = 16 Return Lcd_hyouji: Locate 1 , 10 : Lcd " " Locate 2 , 10 : Lcd " " If Att_data < 10 Then Locate 1 , 11 : Lcd Att_data Else Locate 1 , 10 : Lcd Att_data End If If Att_step = 1 Then Locate 2 , 11 : Lcd Att_step Else Locate 2 , 10 : Lcd Att_step End If Return Updown: If Pina.1 = 0 Then Att_data = Att_data + Att_step Else Att_data = Att_data - att_step End If If Att_data < 0 Then Att_data = 0 If Att_data > 70 Then Att_data = 69 Gosub Lcd_hyouji Return Att_dataout: O_data_1 = Str(att_data) N = Len(o_data_1) If N = 2 Then O_data_2 = Left(o_data_1 , 1) End If O_data_3 = Right(o_data_1 , 1) Select Case N Case 1 Gosub Att_set_1 Gosub Att_reset Case 2 Gosub Att_set_1 Gosub Att_set_2 End Select Return Att_set_1: Select Case O_data_3 Case "0" Reset Portc.1 Reset Portc.2 Reset Portc.4 Reset Portc.5 Case "1" Set Portc.1 Reset Portc.2 Reset Portc.4 Reset Portc.5 Case "2" Set Portc.4 Reset Portc.1 Reset Portc.2 Reset Portc.5 Case "3" Set Portc.5 Reset Portc.1 Reset Portc.2 Reset Portc.4 Case "4" Set Portc.2 Reset Portc.1 Reset Portc.4 Reset Portc.5 Case "5" Set Portc.1 Set Portc.2 Reset Portc.4 Reset Portc.5 Case "6" Set Portc.2 Set Portc.4 Reset Portc.1 Reset Portc.5 Case "7" Set Portc.2 Set Portc.5 Reset Portc.1 Reset Portc.4 Case "8" Set Portc.1 Set Portc.2 Set Portc.5 Reset Portc.4 Case "9" Set Portc.2 Set Portc.4 Set Portc.5 Reset Portc.1 End Select Return Att_set_2: Select Case O_data_2 Case "0" Reset Portc.0 Reset Portc.3 Reset Portc.6 Case "1" Set Portc.3 Reset Portc.0 Reset Portc.6 Case "2" Set Portc.6 Reset Portc.0 Reset Portc.3 Case "3" Set Portc.0 Reset Portc.3 Reset Portc.6 Case "4" Set Portc.0 Set Portc.3 Reset Portc.6 Case "5" Set Portc.0 Set Portc.6 Reset Portc.3 Case "6" Set Portc.0 Set Portc.3 Set Portc.6 End Select Return Att_reset: Reset Portc.0 Reset Portc.3 Reset Portc.6 Return